package com.application.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import java.util.List;

public class ViewPagerAdapter extends FragmentStateAdapter {
    private final List<Fragment> myFragmentList;
    private final List<String> myTitleList;

    public ViewPagerAdapter(@NonNull Fragment fragment,List<Fragment> fragmentList,List<String> titleList) {
        super(fragment);
        myFragmentList=fragmentList;
        myTitleList=titleList;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return myFragmentList.get(position);
    }

    @Override
    public int getItemCount() {
        return myFragmentList.size();
    }

    public String getTitle(int position) {
        return myTitleList.get(position);
    }
}
